package com.eedi.framework.notify.dal.mapper;

import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.notify.controller.sys.vo.template.SysNotifyTemplatePageReq;
import com.eedi.framework.notify.dal.dataobject.SysNotifyTemplateDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface NotifyTemplateMapper extends BaseMapperX<SysNotifyTemplateDO> {

    default SysNotifyTemplateDO selectByCode(String code) {
        return selectOne(SysNotifyTemplateDO::getSysNotifyCode, code);
    }

    default PageResult<SysNotifyTemplateDO> selectPage(SysNotifyTemplatePageReq reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SysNotifyTemplateDO>()
                .likeIfPresent(SysNotifyTemplateDO::getSysNotifyCode, reqVO.getSysNotifyCode())
                .likeIfPresent(SysNotifyTemplateDO::getSysNotifyName, reqVO.getSysNotifyName())
                .eqIfPresent(SysNotifyTemplateDO::getSysNotifyStatus, reqVO.getSysNotifyStatus())
                .betweenIfPresent(SysNotifyTemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SysNotifyTemplateDO::getId));
    }

}
